import axios from "axios";
import {getCookit} from './index'

const request = axios.create({
    timeout: 3000
})


// 请求拦截
request.interceptors.request.use(config => {
    const token = getCookit()

    if(token) {
        config.headers.authorization = token
    }
    return config
})

// 响应拦截
request.interceptors.response.use(config => {
    return config.data
}, err => {
    return Promise.reject(err)
})

export default request